package band.wukong.practice.netty.definitiveguide2nd.ch0304;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LineBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;

/**
 * Desc:
 * author: wukonggg@139.com
 */
public class TimeClientChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        // 1.原始
//        ch.pipeline().addLast(new TimeClientChannelHandler());

        // 2.有问题
//        ch.pipeline().addLast(new TimeClientChannelHandler2());

        // 3.支持粘包
        ch.pipeline().addLast(new LineBasedFrameDecoder(1024));
        ch.pipeline().addLast(new StringDecoder());
        ch.pipeline().addLast(new TimeClientChannelHandler3());
    }
}
